home *** CD-ROM | disk | FTP | other *** search
- Path: news.ichange.com!newsmaster
- From: Jesse Liberty <jl@staff.ichange.com>
- Newsgroups: comp.lang.c++
- Subject: Re: Help! Newbie question ...
- Date: Tue, 19 Mar 1996 11:58:37 -0500
- Organization: AT&T
- Message-ID: <314EE7BD.16BD@staff.ichange.com>
- References: <4ilkfu$41q@Kaos.deepcove.com> <314EB00C.34BD@bnr.ca>
- NNTP-Posting-Host: 140.244.99.60
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win95; I)
- CC: jl@staff.ichange.com
-
- Joseph Bell wrote:
- >
- > Sean Affleck wrote:
- > >
- > > Is this legal ?
- > >
- > > class A {...};
- > >
- > > A f();
- > >
- > > main() {
- > > A a = f();
- > > }
- > >
- > > A f()
- > > {
- > > A fa;
- > > return fa;
- > > }
- > >
- >
- > Yes, this is perfectly legal, but with a caveat. If you want to do this
- > you should define a _copy constructor_. ...
-
- Well, yes, if you were going to make a copy and pass it by value you'd want a copy constructor IF class A had any pointers
- (of course, if it didn't have pointers, a shallow copy as made by the default copy constructor would no doubt be just fine).
- The other issue, however, is that you almost certainly don't want to be passing this object around by value.
- ------
- Jesse Liberty [AT&T New Media Services]
- jl@staff.ichange.com ZDNet: 72241,72
- Teach Yourself C++ In 21 Days. Sams 1994
- Teach Yourself MORE C++ In 21 Days. Sams 1996
- Teach Yourself ANSI C++ In 21 Days. Sams 1996
- C++: An Introduction To Programming. Que 1996
-